package rlm.helper;

import org.drools.runtime.rule.RuleContext;

public class RuleDebugger {
	private static Debugger debugger;
	public static Debugger getDebugger(){
		if (debugger == null)
			debugger = new SiletDebugger();
		
		return debugger;
	}
	
	public static void debug(RuleContext context){
		getDebugger().debug(context);
	}
	public static void debug(String name){
		getDebugger().debug(name);
	}
	
	static interface Debugger{
		public void debug(RuleContext context);
		public void debug(String ruleName);
	}
	
	static class SiletDebugger implements Debugger{
		@Override
		public void debug(RuleContext context){
			// debugger should neither be seen nor heard!
		}

		@Override
		public void debug(String string) {
		}
	}
	
	static class NoisyDebugger implements Debugger{

		@Override
		public void debug(RuleContext context) {
			String ans = context.getRule().getName();
			System.out.println(ans + " :: "+context.getActivation().getFactHandles().size());
		}

		@Override
		public void debug(String ruleName) {
			System.out.println(ruleName+" :: ");
		}	
	}
}
